<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
	<meta content="yes" name="apple-mobile-web-app-capable">
	<meta content="black" name="apple-mobile-web-app-status-bar-style">
	<title>我的助理</title>
    <script src="/Public/Home/js/zepto.min.js"></script>
    <link href="/Public/Home/css/weui.min.css" rel="stylesheet">
	<link rel="stylesheet" href="/Public/Home/SaleManager/stylesheets/index.css">
	<link rel="stylesheet" href="/Public/Home/SaleManager/stylesheets/dropload.css">
</head>
<body>
<div class='dorp_down_fororder'>
	<div class="mySaleMan">
		<header class = "all_header">
            <a class = "h_back_1" style='flex: 1;' href="/Home/SaleManager/Salemanager/index"><img src="/Public/Home/SaleManager/images/back_icon.png" alt="" style="width:30px;vertical-align: middle;"></a>
            <span class = "h_title">我的助理</span>
            <a class = "h_add" href="/Home/SaleManager/Salemanager/addSaleman/t/assistant">添加助理</a>
        </header>
		<div class="weui-cells">
		<!-- 我的业务员列表 -->
		<!-- <div class="weui-cell">
		        <div class="weui-cell__hd sale_imgs" data-uid='<?php echo ($myself["id"]); ?>' data-role-id='<?php echo ($v["role_id"]); ?>'>
		       	 <?php if($myself["head_img"] != ''): ?><img class = "sale_img" src="<?php echo ($myself["head_img"]); ?>" alt="暂无">
					  <?php else: ?> <img class = "sale_img" src="/Public/Home/SaleManager/images/people.png" alt="暂无"><?php endif; ?>
		       	 <img class = "sale_img" src="<?php echo ($v["head_img"]); ?>" alt="暂无">
		        </div>
		        <div class="weui-cell__bd">
		          <p class = "sale_man"><?php echo ($myself["real_name"]); ?></p>
		        </div>
		        <div class="weui-cell__ft">
		        	<span class = "change_saleman" data-userid='<?php echo ($myself["id"]); ?>'>更换</span>｜
		        	<span class = "sale_del" data-userid='<?php echo ($myself["id"]); ?>'>删除</span>
		        </div>
	    		</div> -->
		<?php if(is_array($lists)): $i = 0; $__LIST__ = $lists;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><div class="weui-cell">
		        <div class="weui-cell__hd sale_imgs" data-uid='<?php echo ($v["id"]); ?>' data-role-id='<?php echo ($v["role_id"]); ?>'>
		       	 <?php if($v["head_img"] != ''): ?><img class = "sale_img" src="<?php echo ($v["head_img"]); ?>" alt="暂无">
					  <?php else: ?> <img class = "sale_img" src="/Public/Home/SaleManager/images/people.png" alt="暂无"><?php endif; ?>
		       	 <!-- <img class = "sale_img" src="<?php echo ($v["head_img"]); ?>" alt="暂无"> -->
		        </div>
		        <div class="weui-cell__bd">
		          <p class = "sale_man"><?php echo ($v["real_name"]); ?></p>
		        </div>
		        <div class="weui-cell__ft">
		        	<span class = "change_saleman" data-userid='<?php echo ($v["id"]); ?>' data-role-id='<?php echo ($v["role_id"]); ?>'>更换</span>｜
		        	<span class = "sale_del" data-userid='<?php echo ($v["id"]); ?>' data-role-id='<?php echo ($v["role_id"]); ?>'>编辑</span>
		        </div>
	    		</div><?php endforeach; endif; else: echo "" ;endif; ?>
		<div class="js_dialog" id="confirm_dialog" style="display: none;">
      <div class="weui-mask"></div>
      <div class="weui-dialog">
        <div class="weui-dialog__bd"></div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确 定</a>
        </div>
      </div>
    </div>
    <div class="js_dialog" id="iosDialog1" style="display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
        <div class="weui-dialog__bd confir_content"></div>
        <div class="weui-dialog__ft">
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default cancel-btn">取消</a>
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary ok-btn">确定</a>
        </div>
    </div>
</div>
 <div class="js_dialog" id="jsconfiroms" style="display: none;">
    <div class="weui-mask"></div>
    <div class="weui-dialog">
        <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
        <div class="weui-dialog__bd confir_content"></div>
        <div class="weui-dialog__ft">
            
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary oksss-btn">确定</a>
            <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_default cancelsss-btn">取消</a>
        </div>
    </div>
</div>


  <script type="text/javascript">
	var saleManagerStatus; //操作返回状态
	$(document).ready(function() { 
		saleManagerStatus='';
		saleManagerStatus ='<?php echo ($status); ?>';  //success,成功；error,错误
		msg ='<?php echo ($msg); ?>';
		if(saleManagerStatus=='success'||saleManagerStatus=='validatefail'){
			$('.weui-dialog__bd').html(msg);
     		$('#confirm_dialog').css('display','block');
     		//saleManagerStatus='formSubmitTrue';
		}
		if(saleManagerStatus=='error'){ 
			$('.weui-dialog__bd').html(msg);
     		$('#confirm_dialog').css('display','block');
     		//saleManagerStatus='formSubmitTrue';
		}
	}); 
	//关闭弹出框
	$(document).on('click','.weui-dialog__btn_primary',function(){
		$('#confirm_dialog').css('display','none');
		if(saleManagerStatus=='error'){
			history.go(-1);
		}
	}); 
	
	$(document).on('click','.cancelsss-btn',function(){
		$('#jsconfiroms').css('display','none');
	});
  </script>
    </div>
	</div>
	</div>
	<script src = "/Public/Home/SaleManager/js/androidback.js"></script>
	<!-- <script src = "/Public/Home/SaleManager/js/index.js"></script> -->
	<script src = "/Public/Home/SaleManager/js/dropload.min.js"></script>
	<script>
		var sessioncode;
		var nosesstion_url;
		var myself = '<?php echo ($myself["id"]); ?>';
		var targetUserId ;
		var saleClass;
	 	//删除事件
	/*  	$(document).on('click','.change_saleman',function(){
	 		if($(this).attr('data-userid').trim()==myself){
				$('.weui-dialog__bd').html("不能更换自己");
	     		$('#confirm_dialog').css('display','block');
	     		return false;
			}
	 			
	 	}) */
	 	//更换自己
	 	$(document).on("click",'.change_saleman',function () {
				 userId = $(this).attr('data-userid');
				 roleId = $(this).attr('data-role-id');
				if($(this).attr('data-userid').trim()==myself){
					$('.weui-dialog__bd').html("不能更换自己");
		     		$('#confirm_dialog').css('display','block');
		     		return false;
				}
				window.location.href = '/Home/SaleManager/County/changeSale/userid/'+userId+'/t/assistant';
			});
	 		//查看信息
			$(document).on("click",'.sale_imgs',function () {
				var userId = $(this).attr('data-uid');
				roleId = $(this).attr('data-role-id');
				window.location.href = '/Home/SaleManager/County/saleInfos/userId/'+userId;
			});
	 		//编辑
 		 $(document).on("click",".sale_del",function(){
			saleClass = $(this);targetUserId
			targetUserId=$(this).attr('data-userid').trim();
			window.location.href='/Home/SaleManager/Salemanager/editAssistant/userId/'+targetUserId;
			/* if($(this).attr('data-userid').trim()==myself){
				$('.weui-dialog__bd').html("不能删除自己");
	     		$('#confirm_dialog').css('display','block');
	     		return false;
			}
			$('#jsconfiroms').css('display','block');
			$('.confir_content').html('确定要删除?'); */
			  
		})  
		//编辑确认事件
		/*  $(document).on("click",".sale_del",function(){
			 	saleClass = $(this);
				targetUserId=$(this).attr('data-userid').trim();
			$.ajax({
                url: "/Home/SaleManager/Salemanager/editAssistant/t/assistant",
                type: 'POST',
                data: {'userid':targetUserId},
                async: false,
                cache: false,
               	dataType:"json",
                success: function (returndata) {
                	//session失效
                	// 我的业务员
					saleClass.parents(".weui-cell").remove();
					
               	 	if(returndata.code==2028){
               	 		sessioncode=2028;
               	 		nosesstion_url=returndata.data;
	        	       	 	$('.weui-dialog__bd').html(returndata.msg);
	        	     		$('#confirm_dialog').css('display','block');
               	 	}else{
               	 		$('#jsconfiroms').css('display','none');
	               	 	$('.weui-dialog__bd').html('删除成功');
	             		$('#confirm_dialog').css('display','block');
               	 	}
                		
                },
                error: function (returndata) {
                		$('.weui-dialog__bd').html("未知错误");
             		$('#confirm_dialog').css('display','block');
                }
            });
		}) */
		$(document).on('click','.weui-dialog__btn_primary',function(){
			if(sessioncode==2028){
				window.location.href=nosesstion_url;
			}
			if(targetUserId == myself){
				return false;
			}
		})
		//下拉刷新
		var LoadEnd = false;
	 // 每页展示10个
		var counter = 0;
		var num = 10;
    		var pageStart = 0;
		var dropload =$('.mySaleMan').dropload({
			scrollArea : window,
			loadDownFn : function(me){
				
				if(counter==0){
					counter++;
					 pageStart = counter*num;
                     me.resetload();
					return false;
				}
				// 锁定
                me.lock();
		        $.ajax({
		            type: 'GET',
		            url: '',
		            data:{'pageStart':pageStart},
		            dataType: 'json',
		            success: function(data){
		            		var vhtml='';
		            		counter++;
                        pageStart = counter*num+1;
	                	 	LoadEnd=true;
	                	 	if(data.data==null ||data.data=='undefined'){
	                	 		 me.noData();
	                	 		 me.unlock()
	    		                // 代码执行后必须重置
	    		                 me.resetload();
	                	 		 return false;
	                	 	}
	                	 	$(data.data).each(function(i,val) { 
	                	 		vhtml+='<div class="weui-cell">';
	                	 		vhtml+='<div class="weui-cell__hd sale_imgs" data-uid='+val.id+' data-role-id='+val.role_id+'>';
	                	 		if(val.head_img!=''){
	                	 			vhtml+='<img class="sale_img" src="'+val.head_img+'" alt="暂无">';
	                	 		}else{
	                	 			vhtml+='<img class="sale_img" src="/Public/Home/SaleManager/images/people.png" alt="暂无">';
	                	 		}
	                	 		vhtml+='</div>';
	                	 		vhtml+='<div class="weui-cell__bd">';
	                	 		vhtml+='<p class="sale_man">'+val.real_name+'</p> </div>';
	                	 		vhtml+='<div class="weui-cell__ft">';
	                	 		vhtml+='<span class="change_saleman" data-userid="'+val.id+'" data-role-id="'+val.role_id+'">更换</span>｜';
	                	 		vhtml+='<span class="sale_del" data-userid="'+val.id+'" data-role-id="'+val.role_id+'">删除</span>';
							vhtml+='</div></div>'; 
						}); 
	                	 	if(vhtml!=''){
	                	 		$('.weui-cells').append(vhtml);
	                	 	}else{
	                	 		// 无数据
	                         me.noData();
	                	 	}
	                		me.unlock()
		                // 代码执行后必须重置
		                me.resetload();
		            },
		            error: function(xhr, type){
		            		me.unlock()
                        // 无数据
                        me.noData();
		                me.resetload();
		            }
		        });
		    }
		});
	</script>
</body>
</html>